package world.snowcrystal.nova.model.enums;

import lombok.Getter;
import org.springframework.lang.Nullable;

/**
 * reviewStatus    int      default 0                 not null comment '审核状态：0-待审核, 1-通过, 2-拒绝',
 */
@Getter
public enum ReviewStatusEnum {


    PENDING_REVIEW(0, "待审核"),
    APPROVED(1, "通过"),
    REJECTED(2, "拒绝"),
    ;
    private int value;
    private String text;


    ReviewStatusEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }


    public static ReviewStatusEnum getByText(String text) {
        for (ReviewStatusEnum reviewStatusEnum : ReviewStatusEnum.values()) {
            if (reviewStatusEnum.text.equals(text)) {
                return reviewStatusEnum;
            }
        }
        return null;
    }

    public static ReviewStatusEnum get(@Nullable Integer value) {
        if (value == null) {
            return null;
        }
        for (ReviewStatusEnum reviewStatusEnum : ReviewStatusEnum.values()) {
            if (reviewStatusEnum.value == value) {
                return reviewStatusEnum;
            }
        }
        return null;
    }

}
